package edu.suda.xsap.service.impl;

import edu.suda.xsap.dto.ClassRecordDto;
import edu.suda.xsap.dto.convert.ClassRecordConvert;
import edu.suda.xsap.entity.ClassRecord;
import edu.suda.xsap.mapper.ClassRecordMapper;
import edu.suda.xsap.service.ClassRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ClassRecordServiceImpl implements ClassRecordService {
@Autowired
private ClassRecordMapper classRecordMapper;
@Autowired
private ClassRecordConvert classRecordConvert;
    @Override
    public void delete(Integer id) {
        classRecordMapper.delete(id);
    }

    @Override
    public List<ClassRecordDto> findAll() {
        return classRecordConvert.toDtoList(classRecordMapper.findAll());
    }

    @Override
    public ClassRecordDto findById(Integer id) {

        return classRecordConvert.toDto(classRecordMapper.findById(id));
    }

    @Override
    public List<ClassRecordDto>  findByMemberId(Integer memberId) {
        return classRecordConvert.toDtoList(classRecordMapper.findByMemberId(memberId));
    }

    @Override
    public List<ClassRecordDto>  findByScheduleId(Integer scheduleId) {
        return classRecordConvert.toDtoList(classRecordMapper.findByScheduleId(scheduleId));
    }

    @Override
    public void save(ClassRecord classRecord) {
        classRecordMapper.save(classRecord);
    }
}
